#include <iostream>
using namespace std;

int year, cnt;

bool check()
{
	int qian = year / 1000;
	int bai = year / 100 % 10;
	int shi = year / 10 % 10;
	int ge = year % 10;
	if(qian == shi && ge == bai + 1) return true;
	return false;
}
int main()
{
	int n = 5;
	while(n--)
	{
		cin >> year;
		if(check()) cnt++;
	}
	cout << cnt;
	return 0;
}
